package com.zs.oauth2.oauth2authorizationserver.service.impl;

import com.zs.oauth2.api.dto.UserInfo;
import com.zs.oauth2.oauth2authorizationserver.entity.AppUsersEntity;
import com.zs.oauth2.oauth2authorizationserver.repository.UserRepository;
import com.zs.oauth2.oauth2authorizationserver.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * @author madison
 * @description
 * @date 2021/4/4 14:35
 */
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {

    private final UserRepository userRepository;

    @Override
    public UserInfo getUser(String username) {
        AppUsersEntity usersEntity = userRepository.findByUsername(username);
        UserInfo userInfo = new UserInfo();
        BeanUtils.copyProperties(usersEntity, userInfo);
        return userInfo;
    }
}
